package WorldCup2010.DAO;

import java.sql.*;
import java.util.*;
import WorldCup2010.VO.*;

public class Team {
	private ResultSet rs;
	
	public ArrayList<InfoMatch> getAllTeam()
	{
		ArrayList<InfoTeam> list = new ArrayList<InfoTeam>();
		
		ConnectionFactory connectionFactory = ConnectionFactory.getDefaultFactory();
		connectionFactory.createConnection();
		
		String sql = "select nation_name, fifaranking, uniform_home, uniform_away, continent, " +
				"from TEAM";			
			
		rs = connectionFactory.executeQuery(sql);
			
		try {
			while(rs.next())
			{
				InfoTeam mInfoTeam = new InfoTeam();
				mInfoTeam.setNation_name(rs.getString("nation_name"));
				mInfoTeam.setFifaranking(rs.getString("fifaranking"));
				mInfoTeam.setUniform_home(rs.getString("uhome")); 
				mInfoTeam.setUniform_away(rs.getString("uaway"));
				
				list.add(mInfoTeam);	
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	
		connectionFactory.closeConnection();
		return list;
	}
}
